#include "StdAfx.h"
#include "MyCom.h"

CMyCom::CMyCom(void)
{
}

CMyCom::~CMyCom(void)
{
}

void CMyCom::OnDataReceived( void * p_data , UINT16 len )
{
}
void CMyCom::OnEventReceived( UINT32 event_code )
{
	static bool sent = false;

	if( event_code & PORT_EV_RXCHAR )
	{
		MessageBoxA( NULL , "PORT_EV_RXCHAR" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_RXFLAG )
	{
		MessageBoxA( NULL , "PORT_EV_RXFLAG" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_TXEMPTY )
	{
		MessageBoxA( NULL , "PORT_EV_TXEMPTY" , "Hi" , MB_OK );

		if( !sent )
		{
			UINT16 writtenLen = 0;
			this->Write( "at\r\n\0" , 4 , &writtenLen );
			sent = true;
		}

	}
	if( event_code & PORT_EV_CTS )
	{
		MessageBoxA( NULL , "PORT_EV_CTS" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_DSR )
	{
		MessageBoxA( NULL , "PORT_EV_DSR" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_RLSD )
	{
		MessageBoxA( NULL , "PORT_EV_RLSD" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_BREAK )
	{
		MessageBoxA( NULL , "PORT_EV_BREAK" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_ERR )
	{
		MessageBoxA( NULL , "PORT_EV_ERR" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_RING )
	{
		MessageBoxA( NULL , "PORT_EV_RING" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_CTSS )
	{
		MessageBoxA( NULL , "PORT_EV_CTSS" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_DSRS )
	{
		MessageBoxA( NULL , "PORT_EV_DSRS" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_RLSDS )
	{
		MessageBoxA( NULL , "PORT_EV_RLSDS" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_OVERRUN )
	{
		MessageBoxA( NULL , "PORT_EV_OVERRUN" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_TXCHAR )
	{
		MessageBoxA( NULL , "PORT_EV_TXCHAR" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_CONNECTED )
	{
		MessageBoxA( NULL , "PORT_EV_CONNECTED" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_CONNECT_ERR )
	{
		MessageBoxA( NULL , "PORT_EV_CONNECT_ERR" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_FC )
	{
		MessageBoxA( NULL , "PORT_EV_FC" , "Hi" , MB_OK );
	}
	if( event_code & PORT_EV_FCS )
	{
		MessageBoxA( NULL , "PORT_EV_FCS" , "Hi" , MB_OK );
	}
}